[mysqld]
# 使用 xtrabackup-v2 必须制定datadir, 因为操作可能直接对 datadir进行
datadir= '{{ datadir }}'


# 为PXC定制
binlog_format=ROW
default-storage-engine         = InnoDB
innodb_large_prefix=on
innodb_autoinc_lock_mode=2
character_set_server=utf8

# 绑定地址之后只能通过内部网络访问
# 不能使用: 10.*.*.*
bind-address=127.0.0.1

auto-increment-increment = 2
auto-increment-offset = 1


# http://www.percona.com/doc/percona-xtrabackup/2.2/innobackupex/privileges.html\#permissions-and-privileges-needed
# 权限的配置
# xtrapbackup在Donor上执行，因此只需localhost的权限



# 约定:
server-id = '{{ server_id }}'


# wsrep模式不依赖于GTID
# 开启GTID
# enforce_gtid_consistency=1
# gtid_mode=on

# 即便临时作为Slave，也记录自己的binlog
log-slave-updates=1

# master_info_repository=TABLE
# relay_log_info_repository=TABLE

# GENERAL #
user                           = '{{ user }}'
port                           = '{{ port_num }}'
socket                         = '{{ socket }}'
pid-file                       = '{{ pid }}'

# MyISAM #
key-buffer-size                = 32M
myisam-recover                 = FORCE,BACKUP


ft-min-word-len = 4
event-scheduler = 0

# SAFETY #
max-allowed-packet             = 16M

skip-name-resolve
max_connections = 2000
max_connect_errors = 10

back-log = 500

character-set-client-handshake = 1
character-set-server = utf8mb4
character-set-client = utf8mb4
collation-server = utf8mb4_unicode_ci

#character-set-client-handshake=1
#character-set-client=utf8
#character-set-server=utf8
#collation-server=utf8_general_ci



#key-buffer-size = 256M
table-open-cache = 2048
max-allowed-packet = 2048M
slave-skip-errors = all                       #Skip duplicated key
sort-buffer-size = 4M
join-buffer-size = 8M
thread-cache-size = 50
concurrent-insert = 2

thread-stack = 192K
net-buffer-length = 8K
read-buffer-size = 256K
read-rnd-buffer-size = 16M
bulk-insert-buffer-size = 64M

# 采用thread pool来处理连接
#thread-handling=pool-of-threads
# 新线程创建等待时间，, 单位为10ms，50即为500ms
#thread-pool-stall-limit = 50


sql-mode                       = STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION
sysdate-is-now                 = 1
innodb                         = FORCE
innodb-strict-mode             = 1


# BINARY LOGGING #
log-bin                        = '{{ bin_log }}'
expire-logs-days               = 5
# LOGGING #
# log-output=file 默认就是FILE
log-error                      = /usr/local/mysql/log/mysql-error.log
long-query-time = 0.3
# log-queries-not-using-indexes  = 1
slow-query-log                 = 1
slow-query-log-file            = /usr/local/mysql/log/mysql-slow.log

# 默认为0(MySQL不控制binlog的输出)
# sync-binlog                    = 1

# CACHES AND LIMITS #

tmp-table-size                 = 32M
max-heap-table-size            = 32M

# 频繁修改的表不适合做query-cache, 否则反而影响效率
query-cache-type               = 0
query-cache-size               = 0
# query-cache-limit = 2M
# query-cache-min-res-unit = 512

thread-cache-size              = 100
open-files-limit               = 65535
table-definition-cache         = 1024
table-open-cache               = 4096

# INNODB #
innodb-flush-method            = O_DIRECT
innodb-log-files-in-group      = 2

# innodb-file-per-table = 1设置之后， 下面的配置基本失效
innodb_data_file_path = ibdata1:10M:autoextend
innodb-thread-concurrency = 32
innodb-log-file-size           = 256M
innodb-flush-log-at-trx-commit = 2
innodb-file-per-table          = 1
innodb-large-prefix            = on
# 内存: 全部内存*0.7
#innodb-buffer-pool-size = 8G

performance-schema = 0
net-read-timeout = 60

# innodb-open-files 在MySQL5.6 auto-sized
# 来自May2
innodb-rollback-on-timeout
innodb-status-file = 1


# http://dev.mysql.com/doc/refman/5.6/en/innodb-performance-multiple_io_threads.html
# http://zhan.renren.com/formysql\?tagId\=3942\&checked\=true
# 从MySQL 5.5
# innodb_file_io_threads = 4
innodb-read-io-threads = 16
innodb-write-io-threads = 8

innodb-io-capacity = 2000
# innodb-stats-update-need-lock = 0 # MySQL 5.6中无效
# innodb-stats-auto-update = 0
innodb-old-blocks-pct = 75
# innodb-adaptive-flushing-method = "estimate"
# innodb-adaptive-flushing = 1

# https://www.facebook.com/notes/mysql-at-facebook/repeatable-read-versus-read-committed-for-innodb/244956410932
# READ-COMMITTED 每次QUERY都要求调用: read_view_open_now, 而REPEATABLE-READ每次Transaction中只要求一次
# REPEATABLE-READ 会导致读写不同步
transaction-isolation = READ-COMMITTED

innodb-sync-spin-loops = 100
innodb-spin-wait-delay = 30




innodb-file-format = "Barracuda"
innodb-file-format-max = "Barracuda"


wait_timeout=28800
interactive_timeout=1800

# 等保3，登陆控制
# https://www.cnblogs.com/zhenxing/p/11050823.html
#plugin-load-add                                 = connection_control.so
#connection-control                              = FORCE
#connection-control-failed-login-attempts        = FORCE
# 响应延迟的最小时间，默认30000微秒，30秒
#connection_control_min_connection_delay         = 300000
# 响应延迟的最大时间，默认约24天
#connection_control_max_connection_delay         = 2147483647
# 失败尝试的次数，默认为5，表示当连接失败3次后启用连接控制，0表示不开启
#connection_control_failed_connections_threshold = 5

# 等保3，密码验证要求
# http://dev.mysql.com/doc/refman/5.6/en/validate-password-plugin.html\#validate-password-plugin-installation
# https://blog.csdn.net/wltsysterm/article/details/79649484
#plugin-load-add                                 = validate_password.so

# validate-password=ON/OFF/FORCE/FORCE_PLUS_PERMANENT: 决定是否使用该插件(及强制/永久强制使用)。
#validate-password=FORCE_PLUS_PERMANENT
# 密码最小长度
#validate_password_length                        = 8
# 密码至少要包含的小写字母个数和大写字母个数
#validate_password_mixed_case_count              = 1
# 密码至少要包含的数字个数
#validate_password_number_count                  = 1
# 密码至少要包含的特殊字符数
#validate_password_special_char_count            = 1
# 密码强度检查等级，0/LOW:只检查长度、1/MEDIUM:检查长度、数字、大小写、特殊字符、2/STRONG:2/STRONG：检查长度、数字、大小写、特殊字符字典文件。
#validate_password_policy                        = 1

#plugin-load-add                                 = audit_log.so
#audit-log=FORCE_PLUS_PERMANENT


local_infile=off
# have_symlink=off
symbolic-links=off
# 设置general log日志
# https://blog.csdn.net/szgyunyun/article/details/121993852
# 开启general log日志
general-log = 1
# 定义general log日志的位置
general_log_file = /usr/local/mysql/log/mysql_general.log
